<?php

/**
 * MVM_MALL 网上商店系统  公告牌分类管理
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-07-15 $
 * $Id: board_category.inc.php  www.mvmmall.com$
 * ---------------------------------------------
*/

if(!defined('MVMMALL') || !defined('IN_ADMINCP')) exit('Access Denied');
if ($action=='list') {
    $ps_name = dhtmlchars($ps_name);
    $rt      = $db->get_one("SELECT board_name_code,uid,board_title FROM `{$tablepre}badmin_table` WHERE uid = '$uid'");
    @extract($rt,EXTR_OVERWRITE);
    $board_name_code = dhtmlchars($board_name_code);
    $result          = $db->query("SELECT * FROM `{$tablepre}bcategory` WHERE ps_name = '$board_name_code'");
    while ($rt       = $db->fetch_array($result)) {
         $rt['del']  = "admincp.php?module=$module&action=del&uid=$rt[uid]";
    	 $cat_rt[]   = $rt;
    }
    require_once template('board_category');
    footer();

} elseif($action=='add') {
    $category_name  = dhtmlchars($category_name);
    $ps_name        = dhtmlchars($ps_name);
    $nums           = $db->counter("{$tablepre}bcategory","category_name = '$category_name' and ps_name='$ps_name'","*");
    $nums >0       &&  admin_msg('cate_use');
    $db->query("INSERT INTO `{$tablepre}bcategory` SET category_name = '$category_name',ps_name='$ps_name'");
    $cache->put_cache('board_cat');
    admin_msg('success',dreferer());
} elseif ($action=='edit' && is_numeric($uid)) {
    $category_name = dhtmlchars($category_name);
    $ps_name       = dhtmlchars($ps_name);
    $nums          = $db->counter("{$tablepre}bcategory","category_name = '$category_name' and ps_name='$ps_name' and uid <>$uid");
    $nums >0       &&  admin_msg('cate_use');
    $db->query("UPDATE `{$tablepre}bcategory` SET category_name = '$category_name' WHERE uid = '$uid'");
    $cache->put_cache('board_cat');
    admin_msg('success',dreferer());
}  elseif ($action=='del' && is_numeric($uid)) {
    $db->query("DELETE FROM `{$tablepre}bcategory` WHERE  uid = '$uid'");
    $cache->put_cache('board_cat');
    admin_msg('success',dreferer());
} else {
    admin_msg('pass_worng');
}
